package com.abyss.transformation.datastream;


import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * 演示两个流的合并union算子
 */
public class UnionDemo {
    public static void main(String[] args) throws Exception {
        // 1. Env
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        // 2. source
        DataStreamSource<String> source1 = env.fromElements("haha", "heihei", "hehe");
        DataStreamSource<String> source2 = env.fromElements("lala", "papa", "guagua");
        DataStreamSource<Integer> source3 = env.fromElements(1, 2, 3, 4, 5, 6, 7);

        // 3. union
        DataStream<String> unioned1 = source1.union(source2);

        // 4. print and execute
        unioned1.print();
        env.execute();
    }
}